<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>banner</title>
</head>
<body>
    <% include ./components/top.ejs %>
    <% if(typeof mod_data == 'undefined'){ %>
    <form action="?" method="post">
        标题：<input type="text" name="标题" id=""><br>
        简介：<textarea name="简介" id="" cols="30" rows="10"></textarea><br>
        地址：<input type="text" name="链接地址" id=""><br>
        <input type="submit" value="提交">
    </form>
    <% }else{ %>
    <form action="?" method="post">
        <input type="hidden" name="mod_id" value='<%= mod_data.ID %>'>
        标题：<input type="text" name="标题" value='<%= mod_data.title %>'><br>
        简介：<textarea name="简介" id="" cols="30" rows="10"><%= mod_data.description %></textarea><br>
        地址：<input type="text" name="链接地址" value='<%= mod_data.href %>'><br>
        <input type="submit" value="修改">
    </form>
    <% } %>
    <div class="list">
        <table>
            <thead>
                <th>ID</th>
                <th>标题</th>
                <th>简介</th>
                <th>链接地址</th>
                <th>操作</th>
            </thead>
            <tbody>
            <% for(let i = 0; i < banner_data.length; i++) { %>
                <tr>
                    <td><%= banner_data[i].ID %></td>
                    <td><%= banner_data[i].title %></td>
                    <td><%= banner_data[i].description %></td>
                    <td><%= banner_data[i].href %></td>
                    <td>
                        <a href="?act=mod&&id=<%= banner_data[i].ID %>" >修改</a>                    
                        <a href="?act=del&&id=<%= banner_data[i].ID %>" onclick="return confirm('确认要删除吗？')">删除</a>
                    </td>
                </tr>
                
            <% } %>
            </tbody>
        </table>
    </div>
</body>
</html>